import { INDEX, renderFileJump } from '@/utils/tableColumn';
import type { IColumnsOption } from 'vc';
import { HbSubjectEnum } from '../../apis';

export function useTable(hbSubjectType: HbSubjectEnum) {
  const columns = ref<Nullable<IColumnsOption>[]>([
    { ...INDEX },
    {
      width: 111,
      field: 'noticeDate',
      title: '发布日期',
      align: 'center',
      sortable: true
    },
    hbSubjectType === HbSubjectEnum.KEYSEWAGE
      ? {
          width: 137,
          field: 'evaluationType',
          title: '排污类型',
          headerAlign: 'center',
          align: 'left'
        }
      : null,
    {
      width: 111,
      field: 'tagYear',
      title: '认定年度',
      align: 'center',
      sortable: true
    },
    [HbSubjectEnum.ENERGYCONSUMPTION, HbSubjectEnum.CARBONEMISSION].includes(hbSubjectType)
      ? {
          width: 150,
          field: 'postLevel',
          title: HbSubjectEnum.ENERGYCONSUMPTION === hbSubjectType ? '认定级别' : '碳市场等级',
          align: 'center',
          sortable: true
        }
      : null,
    {
      field: 'tagName',
      title: '信息来源',
      align: 'center',
      slots: {
        default: ({ row }) => {
          return renderFileJump(row, row.tagName);
        }
      }
    },
    {
      width: 300,
      field: 'postAgency',
      title: '认定单位',
      sortable: true
    }
  ]);

  return {
    columns
  };
}
